﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TTSBLL;
using TTSModel;

public partial class CheckForTesting : System.Web.UI.Page
{
    private int id { get { return Convert.ToInt32(ViewState["id"].ToString()); } set { ViewState["id"] = value; } }
     private T0002028Detail singleAssembleDetailBLL;
     private IList<T0002028DetailInfo> singleAssembleDetailList;

     public CheckForTesting()
     {
         singleAssembleDetailBLL = new T0002028Detail();
     }
     protected void Page_Load(object sender, EventArgs e)
     {
         if (!IsPostBack)
         {
             // tcode = this.SNInputing.Text.Trim();
             //BindData();
             this.GridView1.PagerSettings.Visible = false;//隐藏自带的分页
             id = Convert.ToInt32(Request.QueryString["ID"]);
             //  this.SNInputing.Text = Request.QueryString["SN"].ToString();
             BindData();
         }

     }
  
    protected void BindData()
    {
        this.GridView1.Visible = true;
        singleAssembleDetailList = singleAssembleDetailBLL.LoadEntities(id);
        this.GridView1.DataSource = singleAssembleDetailList;
        this.GridView1.DataBind();
        this.ddlCurrentPage.Items.Clear();
        for (int i = 1; i <= this.GridView1.PageCount; i++)
        {
            this.ddlCurrentPage.Items.Add(i.ToString());
        }
        this.ddlCurrentPage.SelectedIndex = this.GridView1.PageIndex;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //Response.Redirect("~/checkForForeigners/T0002028SummaryTesting.aspx");
        string url = "~/search/checkForForeigners/T0002028SummaryTesting.aspx?SN=" + singleAssembleDetailBLL.LoadEntities(Convert.ToInt32(Request.QueryString["ID"].ToString()))[0].SN;
        Response.Redirect(url);
    }

   
    /// <summary>
    /// 重新绑定
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.GridView1.PageIndex = this.ddlCurrentPage.SelectedIndex;
        BindData();
    }
    protected void lnkbtnFrist_Click(object sender, EventArgs e)
    {
        this.GridView1.PageIndex = 0;
        BindData();
    }
    protected void lnkbtnPre_Click(object sender, EventArgs e)
    {
        if (this.GridView1.PageIndex > 0)
        {
            this.GridView1.PageIndex = this.GridView1.PageIndex - 1;
            BindData();
        }
    }
    protected void lnkbtnNext_Click(object sender, EventArgs e)
    {
        if (this.GridView1.PageIndex < this.GridView1.PageCount)
        {
            this.GridView1.PageIndex = this.GridView1.PageIndex + 1;
            BindData();
        }
    }
    protected void lnkbtnLast_Click(object sender, EventArgs e)
    {
        this.GridView1.PageIndex = this.GridView1.PageCount;
        BindData();
    }
    protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
    {
        this.lblCurrentPage.Text = string.Format("当前第{0}页/总共{1}页", this.GridView1.PageIndex + 1, this.GridView1.PageCount);

        //遍历所有行设置边框样式
        foreach (TableCell tc in e.Row.Cells)
        {
            tc.Attributes["style"] = "border-color:Black";
        }

        //用索引来取得编号
        /*  if (e.Row.RowIndex != -1)
          {
              int id = GridView1.PageIndex * GridView1.PageSize + e.Row.RowIndex + 1;
              e.Row.Cells[0].Text = id.ToString();
          }*/
    }
}